/**
 * Created by admin on 2017/6/5.
 */
export const date = function (v1, v2) {
  if(v1 && v2) {
    const date1 = v1.substring(0,10).replace(/-/g,"/"),
      date2 = v2.substring(0,10).replace(/-/g,"/");
    return date1 +'-'+ date2;
  }
};

//活动列表
export const status_txt = function (v) {
  switch (v) {
    case 0:
      return '报名未开始';
    case 1:
      return '活动报名中';
    case 2: //活动进行中
      return '报名已截止';
    case 3:
      return '活动已结束';
    case 4:
      return '报名已截止';
    case 5:
      return '活动已满额';
  }
};

export const time = function (v1, v2) {
  if(v1 && v2) {
    const weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      date1 = v1.substring(0,10),
      date2 = v2.substring(0,10),
      _date1 = date1.replace(/-/g,"/"),
      _date2 = date2.replace(/-/g,"/"),
      day1 = weekDay[new Date(date1).getDay()],
      day2 = weekDay[new Date(date2).getDay()],
      time1 = v1.substring(11,16),
      time2 = v2.substring(11,16);
    if(date1==date2){
      return _date1 +' '+ day1 +' '+ time1 + '-' + time2;
    }else{
      return _date1 +' '+ day1 +' '+ time1 + ' - ' + _date2 +' '+ day2 +' '+ time2;
    }
  }
};

//活动详情 上方标签txt & 我的活动列表 & 教练活动列表 & 教练活动详情
export const ac_status_txt = function (v) {
  switch (v) {
    case 0:
      return '报名未开始';
    case 1:
      return '活动报名中';
    case 2:
      return '活动进行中';
    case 3:
      return '活动已结束';
    case 4:
      return '报名已截止';
    case 5:
      return '活动已满额';
  }
};

//活动详情 上方标签 class & 我的报名列表 tag class
export const ac_status = function (v) {
  switch (v) {
    case 1:
      return 'red';
    case 2:
      return 'green';
  }
};

//我的活动列表 大按钮txt
export const user_status_txt = function (s1, s2) {
  switch (s2) {
    case 0:
      return '待付款';
    case 1:
      switch (s1) {
        case 2:
          return '立即签到';
        default:
          return '未签到';
      }
      break;
    case 2:
      return '签到成功';
    case 3:
      return '取消成功';
  }
};
//我的活动列表 大按钮class
export const user_status_class = function (s1, s2) {
  switch (s2) {
    case 0:
      return 'red';
    case 1:
      if( s1==2 ) return 'blue';
      break;
    case 2:
      return 'blue';
  }
};


//我的报名详情 txt
export const register_status_txt = function (s1, s2) {
  switch (s2) {
    case 1:
      switch (s1) {
        case 1:
          return '活动已报名';
        case 2:
          return '活动进行中';
        case 3:
          return '活动已结束';
        case 4:
          return '报名已截止';
        case 5:
          return '活动已满额';
      }
      break;
    case 2:
      return '活动已签到';
    case 3:
      return '报名已取消';
  }
};


//教练 活动列表 大按钮 txt
export const isRewarded = function (v) {
  switch (true) {
    case v==0:
      return '积分已发';
    case v>0:
      return '奖励积分';
  }
};


export const chubAcStatus = function (v) {
  return {
    0: '报名未开始',
    1: '活动报名中',
    2: '报名已截止',
    3: '活动已结束',
    4: '报名已截止',
    5: '活动已满额',
  }[v];
};

export const select_time = function (v1, v2) {
  if(v1 && v2) {
    const weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      date1 = v1.substring(0,10),
      date2 = v2.substring(0,10),
      _date1 = date1.replace(/-/g,"/"),
      _date2 = date2.replace(/-/g,"/"),
      day1 = weekDay[new Date(date1).getDay()],
      day2 = weekDay[new Date(date2).getDay()],
      time1 = v1.substring(11,16),
      time2 = v2.substring(11,16);
    if(date1==date2){
      return _date1 +' '+ day1 +' '+ time1 + '-' + time2;
    }else{
      return _date1 +' '+ day1 +' '+ time1 + ' - ' + _date2 +' '+ day2 +' '+ time2;
    }
  }
};
export const time16 = function(v){
  if(!v) return;
  return v.substring(0,16)
};
//时间过去多久
export const howLong = function (v) {
  const t = new Date().getTime() - new Date(v.replace(/-/g,"/")).getTime(),
    timeMap = {
      d: 86400000,
      h: 3600000,
      m: 60000,
      s: 1000
    },
    d = Math.floor(t/timeMap.d),
    h = Math.floor(t/timeMap.h%24),
    m = Math.floor(t/timeMap.m%60),
    s = Math.floor(t/timeMap.s%60);
  switch(true){
    case d>0:
      return d+'天前';
    case h>0:
      return h+'小时前';
    case m>0:
      return m+'分钟前';
    case s>0:
      return s+'秒前';
  }
};
